<?php
date_default_timezone_set('Asia/Shanghai');
require_once '../utils/common.php';
require_once '../Config.php';
$conn = mysql_connect ( host, username, password );
if (! $conn) {
	die ( "连接失败" . mysql_error () );
}
mysql_select_db ( db, $conn );
$type = $_REQUEST['type'];
$fatherid = $_REQUEST['fatherid'];
if($type == 'add'){
	$name = $_REQUEST['name'];
	$tel = $_REQUEST['tel'];
		$sql = "set names utf8";
		mysql_query($sql);
		$sql = "insert into j_tab_tel(name,tel,fatherid) values ('".$name."','".$tel."',".$fatherid.")";
		mysql_query($sql);
		mysql_close($conn);
		header("Location: TelManager.php?id=$fatherid");
}else if($type == 'update'){
	$id = $_REQUEST['id'];
	$name = $_REQUEST['name'];
	$tel = $_REQUEST['tel'];
		$sql = "set names utf8";
		mysql_query($sql);
		$sql = "update j_tab_tel set name='".$name."',tel='".$tel."' where id=".$id;
		mysql_query($sql);
		mysql_close($conn);
		header("Location: TelManager.php?id=$fatherid");
}else if($type == 'del'){
	$id = $_REQUEST['id'];
	$sql = "delete from j_tab_tel where id=".$id;
	mysql_query($sql);
	mysql_close($conn);
	echo "<script language=\"JavaScript\">\r\n";
	echo " alert(\"删除成功！\");\r\n";
	echo " history.back();\r\n";
	echo "</script>";
	exit;
}



?>